package me.yan.controller;

import jakarta.servlet.http.HttpServletRequest;
import me.yan.api.QiniuCloudService;
import me.yan.constant.Types;
import me.yan.constant.WebConst;
import me.yan.dao.MetaDao;
import me.yan.dto.MetaDto;
import me.yan.dto.cond.ContentCond;
import me.yan.service.attach.AttAchService;
import me.yan.service.comment.CommentService;
import me.yan.service.content.ContentService;
import me.yan.service.log.LogService;
import me.yan.service.meta.MetaService;
import me.yan.service.site.SiteService;
import me.yan.service.user.UserService;
import me.yan.utils.AdminCommons;
import me.yan.utils.Commons;
import me.yan.utils.MapCache;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public abstract class BaseController {

    @Autowired
    public MetaService metaService;

    @Autowired
    public Commons commons;

    @Autowired
    public AdminCommons adminCommons;

    @Autowired
    public UserService userService;

    @Autowired
    public LogService logService;

    @Autowired
    public CommentService commentService;

    @Autowired
    public SiteService siteService;

    @Autowired
    public MetaDao metaDao;

    @Autowired
    public QiniuCloudService qiniuCloudService;

    @Autowired
    public AttAchService attAchService;

    @Autowired
    public ContentService contentService;

    protected MapCache cache=MapCache.single();
    /**
     * 获取blog页面需要的公共数据
     * @param request
     * @return
     */
    public BaseController blogBaseData(HttpServletRequest request, ContentCond contentCond){
//        List<MetaDto> categories = metaService.getMetaList(Types.CATEGORY.getType(), null, WebConst.MAX_POSTS);
//        List<MetaDto> tags = metaService.getMetaList(Types.TAG.getType(), null, WebConst.MAX_POSTS);
        List<MetaDto> links = metaService.getMetaList(Types.LINK.getType(), null, WebConst.MAX_POSTS);
//        request.setAttribute("categories", categories);//分类
//        request.setAttribute("tags", tags);//标签
        request.setAttribute("links", links);
        System.out.println("links->>"+links);
//        PageInfo<ContentDomain> recentlyArticles = contentService.getRecentlyArticle(1, 10);
//        ContentCond cond = new ContentCond();
//        cond.setType(contentCond.getType());
//        request.setAttribute("recentlyArticles", recentlyArticles);
//        List<ArchiveDto> archives = siteService.getArchivesSimple(cond);
//        request.setAttribute("archives", archives);//归档数据

        return this;
    }
}
